<template>
	<view class="text-right" style="flex: 1;">
		<picker :disabled="disabled" @change="PickerChange" :value="index" :range="textList" v-if="textList && textList.length > 0">
			<view class="picker text-black">
				{{index>-1?textList[index]:'无'}}
			</view>
		</picker>
		<picker :disabled="disabled" @change="PickerChange" :value="index" :range="list" v-else>
			<view class="picker text-black">
				{{index>-1?list[index]:'无'}}
			</view>
		</picker>
	</view>
</template>

<script>
	export default{
		props: {
			list: {type: Array},
			value: {type: [String, Number]},
			textList: {type: Array},
			disabled: {type: Boolean, default:() => {return false}}
		},
		mounted() {
			console.log(this.value)
			this.index = this.list.findIndex(item => item == this.value)
		},
		watch:{
			value(cur, old) {
				console.log(cur)
				this.index = this.list.findIndex(item => item == this.value)
			}
		},
		data() {
			return {
				index: 0
			}
		},
		methods:{
			PickerChange(e) {
				this.index = e.detail.value
				console.log(this.list[this.index])
				this.$emit("input", this.list[e.detail.value])
			}
		}
	}
</script>

<style>
</style>
